<html>
<div>
    <form style="background-image: linear-gradient(to top, #479ed3 0%, #72f8c2 100%);
    width: 300px;height: 400px; color: aliceblue; text-align: center; border-radius: 5px;
    margin: 0 auto; margin-top: 50px;
    ">
    <label for="sn">学号：</label>
    <input type="text" name="sn" id="sn">
    <br>
    <label for="pswd">密码：</label>
    <input type="password" name="pswd" id="pswd">
    <br>
    <label for="repswd">确认密码：</label>
    <input type="password" name="repswd" id="repswd">

    <br>
    <label for="sn">性别：</label>
    <input type="text" name="sex" id="sex">
    <br>
    <label for="sn">真实姓名：</label>
    <input type="text" name="realName" id="realName">
    <br>
   
    <input type="button" onclick="register()" value="提交">
    <input type="reset" value="重置">
    <br>
</form>
</div>

<script>
    function fillInfo(){
        let userinfo = localStorage.getItem("userinfo")
        let user = JSON.parse(userinfo);
        document.getElementById("sn").value = user.Sn;
        document.getElementById("sex").value = user.Sex;
        document.getElementById("realName").value = user.Name; 
    }
         fillInfo();
         function updateinfo() {
            var userinfo = new Object();
            userinfo.Sn = document.getElementById("sn").value;
            userinfo.Pswd = document.getElementById("pswd").value;
            userinfo.Repswd = document.getElementById("repswd").value;
            userinfo.Sex = document.getElementById("sex").value;
            userinfo.RealName = document.getElementById("realName").value
            if (userinfo.Pswd !=userinfo.Repswd) {
                alert("输入两次密码不一致，请重新输入");
                return
            }
            fetch("/doUpdateInfo", {
            method: 'post',
            body: JSON.stringify(userinfo)
        }).then(resp => resp.text())  //解码
            .then(data => {
                alert(data);
            })
    
         }
</script>
</html>